package com.ruoyi.common.workflow.util;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author Zzneko
 * @Date 2025/7/31 17:14
 * @Descprition
 **/
@Slf4j
public class BuildVariableUtil<T> {

    public static<T> Map<String, Object> buildVariable(T t) {
        Map<String, Object> variable = new HashMap<>();
        Arrays.stream(t.getClass().getDeclaredFields()).forEach(x->{
            try {
                x.setAccessible(true);
                variable.put(x.getName(),x.get(t));
            } catch (IllegalAccessException e) {
                log.error("变量获取失败",e.getMessage());
            }
        });
        return variable;
    }

}
